#!/usr/bin/env python
##########################################
# written by He Dongjing, SJTU
# create a file
# truncate or add zeros
# make the file size to be the power of 2
##########################################


####################
# functions
####################

# truncate the file with 'file_name' to the size 'file_size'
def trunc_file(file_name, dest_size):
    fp = open(file_name, 'rw+')
    fp.seek(0)
    fp.truncate(dest_size)
    fp.close()

# add zeros to the file with 'file_name', and make the size to be 'file_size'
def add_file(file_name, dest_size, file_size):
    fp = open(file_name, 'a')
    fp.seek(0)
    add_size = dest_size - file_size
    print add_size
    while(add_size):
        fp.write('0')
        add_size = add_size - 1
    fp.close()
